package com.study.dao;

import com.study.domain.Admin;
import com.study.domain.User;
import com.study.util.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class AdminDao {

    private QueryRunner queryRunner = new QueryRunner();


    public Admin login(String name, String password) {
        Admin user = null;
        try {
            user = queryRunner.query(DbUtils.getConnection(), "select * from admin where name ='" + name + "' and password = '" + password + "'", new BeanHandler<>(Admin.class));
        } catch (SQLException | ClassNotFoundException e) {
            e.printStackTrace();
        }
        return user;
    }
}
